/*!
	@file
	@author		Albert Semenov
	@date		08/2008
*/

#ifndef __BASE_MANAGER_H__
#define __BASE_MANAGER_H__

#include <MyGUI.h>
#include <MyGUI_OpenGLPlatform.h>
#include "InputManager.h"

#include "easy2d.h"
using namespace easy2d;


namespace base
{

	class BaseManager :
		public input::InputManager,
		public IEngine::IEventListener
//		public IMouseEventListener
	{
	public:
		BaseManager();
		virtual ~BaseManager();

		bool initialize(IEngine* engine);
		void release();
		void update(unsigned int elapsedTime);
		void render();
		void resize(int width, int height);

		const std::string& getRootMedia();
		void setResourceFilename(const std::string& _flename);
		void addResourceLocation(const std::string& _name, bool _recursive = false);

		virtual void onDeviceRestore();

	protected:
		virtual void setupResources();


		virtual void injectMouseMove(int _absx, int _absy, int _absz);
		virtual void injectMousePress(int _absx, int _absy, MyGUI::MouseButton _id);
		virtual void injectMouseRelease(int _absx, int _absy, MyGUI::MouseButton _id);
		virtual void injectKeyPress(MyGUI::KeyCode _key, MyGUI::Char _text);
		virtual void injectKeyRelease(MyGUI::KeyCode _key);

	private:
		void createGui();
		void destroyGui();

		virtual void createScene() { }

		

	private:
		IEngine* mEngine;
		IVideo* mVideo;
		IInput* mInput;

		MyGUI::Gui* mGUI;
		MyGUI::OpenGLPlatform* mPlatform;

		std::string mRootMedia;
		std::string mResourceFileName;
	};

} // namespace base

#endif // __BASE_MANAGER_H__
